package com.hoodemia.ui;

import net.code.btalk.ui.Constants;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.component.PasswordEditField;

public class StandardPasswordField extends PasswordEditField {

private String placeholder;
	
	public StandardPasswordField(String placeholder, int maxChar, long style) {
		super("", "", maxChar, style);
		this.placeholder = placeholder;
		
		this.setPadding(Constants.TEXT_FIELD_PADDING);
		this.setBorder(Field.VISUAL_STATE_NORMAL, Constants.SIMPLE_GRAY_BORDER);
		this.setBorder(Field.VISUAL_STATE_FOCUS, Constants.SIMPLE_ORANGE_BORDER);
		this.setBorder(Field.VISUAL_STATE_ACTIVE, Constants.SIMPLE_ORANGE_BORDER);
		this.setBackground(Constants.BACKGROUND_WHITE_PLAIN);
	}
	
	protected void paint(Graphics g) {
		// TODO Auto-generated method stub
		int oldColor = g.getColor();
		try {
			g.setColor(0x00000000);
			String test = super.getText();
			if (test == null || test.length() < 1) {
				g.setColor(0x00808080);
				g.drawText(this.placeholder, 0, 0);
			}
			super.paint(g);
		} finally {
			g.setColor(oldColor);
		}
	}

	protected void paintBackground(Graphics g) {
		// TODO Auto-generated method stub
		g.setBackgroundColor(0x00FFFFFF);
		g.clear();
		super.paintBackground(g);
	}
	
	/*public Locale getPreferredInputLocale() {
		// TODO Auto-generated method stub
		return null;
	}

	public int getTextInputStyle() {
		// TODO Auto-generated method stub
		return 0;
	}

	public boolean isUnicodeInputAllowed() {
		// TODO Auto-generated method stub
		return false;
	}

	public void updateInputStyle() {
		// TODO Auto-generated method stub

	}*/

}
